﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using AutoMapper;

using SMG.Domain.Model.System;
using SMG.Domain.Model.Program;
using SMG.Domain.Model.Migration;

using SMG.Application.DTO.System;
using SMG.Application.DTO.Program;
using SMG.Application.DTO.Migration;

namespace SMG.Application.Extension
{
    internal class BootStrapper
    {
        public static void ConfigAutoMapper()
        {
            #region System Mapping

            Mapper.CreateMap<User, UserDto>()
                .ForMember(dest => dest.ID, opt => { opt.MapFrom(source => source.ID.ToString()); })
                .ForMember(dest => dest.PhoneNo, opt => { opt.MapFrom(source => source.PhoneNum); })
                .ForMember(dest => dest.State, opt => { opt.MapFrom(source => (Int32)source.Status); });

            Mapper.CreateMap<UserDto, User>()
                .ForMember(dest => dest.ID, opt => { opt.MapFrom(source => source.ID.ToString()); })
                .ForMember(dest => dest.PhoneNum, opt => { opt.MapFrom(source => source.PhoneNo); })
                .ForMember(dest => dest.Status, opt => { opt.MapFrom(source => (UserStatus)source.State); });

            Mapper.CreateMap<SysDict, SysDictDto>();
            Mapper.CreateMap<SysDictDto, SysDict>();

            #endregion

            #region Program

            Mapper.CreateMap<ProgramBill, ProgramBillDto>();
            Mapper.CreateMap<ProgramBillDto, ProgramBill>();

            Mapper.CreateMap<BillVersionRecord, BillVersionRecordDto>();
            Mapper.CreateMap<BillVersionRecordDto, BillVersionRecord>();

            #endregion

            Mapper.CreateMap<PlayRecord, PlayRecordDto>();
            Mapper.CreateMap<PlayRecordDto, PlayRecord>();

            Mapper.CreateMap<FirstMoveTask, FirstMoveTaskDto>();
            Mapper.CreateMap<FirstMoveTaskDto, FirstMoveTask>();

            Mapper.CreateMap<FirstMoveTaskDetail, FirstMoveTaskDetailDto>();
            Mapper.CreateMap<FirstMoveTaskDetailDto, FirstMoveTaskDetail>();

            Mapper.CreateMap<FirstMoveTaskState, FirstMoveTaskStateDto>();
            Mapper.CreateMap<FirstMoveTaskStateDto, FirstMoveTaskState>();

            Mapper.CreateMap<FirstMoveTaskDetailState, FirstMoveTaskDetailStateDto>();
            Mapper.CreateMap<FirstMoveTaskDetailStateDto, FirstMoveTaskDetailState>();

            Mapper.CreateMap<SecondMoveTask, SecondMoveTaskDto>();
            Mapper.CreateMap<SecondMoveTaskDto, SecondMoveTask>();

            Mapper.CreateMap<SecondMoveTaskDetail, SecondMoveTaskDetailDto>();
            Mapper.CreateMap<SecondMoveTaskDetailDto, SecondMoveTaskDetail>();

            Mapper.CreateMap<Channel, ChannelDto>();
            Mapper.CreateMap<ChannelDto, Channel>();

            Mapper.CreateMap<Device, DeviceDto>();
            Mapper.CreateMap<DeviceDto, Device>();
        }
    }
}
